<template>
  <div class="subject">
    <p>
      <span>{{ obj.num }}</span>
      <span>+</span>
      <span>{{ obj.num1 }}</span>
      <span>=</span>
      <input type="number" v-model.number="sum" />
      <button @click="judge">提交</button>
    </p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      sum: 0,
    };
  },
  props: {
    obj: {
      type: Object,
      require: true,
    },
    index: {
      type: Number,
      require: true,
    },
  },
  methods: {
    judge() {
      this.$emit(
        "judge",
        this.obj.num + this.obj.num1 === this.sum,
        this.index
      );
    },
  },
};
</script>

<style scoped>
.subject {
  margin: 5px;
  padding: 5px;
  font-size: 20px;
}
.subject span {
  display: inline-block;
  text-align: center;
  width: 20px;
}
.subject input {
  width: 50px;
  height: 20px;
}
</style>
